package com.toocms.jinjuhang.ui.index

import androidx.databinding.ObservableField
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.data.index.ConfigureItemData
import com.toocms.jinjuhang.utils.RuleSkip
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.base.MultiItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

/**
 * 左一右二(竖排)
 */
class IndexModuleTwoItemModel(viewModel: BaseViewModel<*>,images: List<ConfigureItemData>) :
    MultiItemViewModel<BaseViewModel<*>>(viewModel) {

    val imageOneUrlObservableField by lazy {
        ObservableField(images[0].cover_path)
    }
    val imageTwoUrlObservableField by lazy {
        ObservableField(images[1].cover_path)
    }
    val imageThreeUrlObservableField by lazy {
        ObservableField(images[2].cover_path)
    }

    val imageOneClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        val itemData = images[0]
        RuleSkip.skip(itemData.target_rule, itemData.param)
    })
    val imageTwoClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        val itemData = images[1]
        RuleSkip.skip(itemData.target_rule, itemData.param)
    })
    val imageThreeClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        val itemData = images[2]
        RuleSkip.skip(itemData.target_rule, itemData.param)
    })


    init {
        itemType = Constants.RecyclerViewItemType.ITEM_TYPE_FIVE
    }
}